package com.jozen.modelbase.netwoek;

import io.reactivex.Observable;
import io.reactivex.ObservableTransformer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * 通用的Rx线程转换类
 * 参考:http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0819/3327.html
 * @author Amos
 */
public class RxSchedulers {

    static final ObservableTransformer schedulersTransformer = (Observable upstream)->
            (upstream).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()
            );

    public static <T> ObservableTransformer<T, T> applySchedulers() {
        return (ObservableTransformer<T, T>) schedulersTransformer;
    }
}